<template>
  <div>
    <detail-banner
      :sightName="sightName"
      :bannerImg="bannerImg"
      :gallaryImgs="gallaryImgs"
    ></detail-banner>
    <detail-header></detail-header>
    <div class="content">
      <detail-list :list="list"></detail-list>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import DetailBanner from "./components/Banner";
import DetailHeader from "./components/Header";
import DetailList from "./components/List";
export default {
  name: "Detail",
  components: {
    DetailBanner,
    DetailHeader,
    DetailList,
  },
  data() {
    return {
      sightName: "",
      bannerImg: "",
      gallaryImgs: [],
      list: [],
    };
  },
  methods: {
    getDetailInfo() {
      axios
        .get(
          "https://www.fastmock.site/mock/4c7a35990c15d8e6700c84cdc193ecc9/api/detail",
          {
            params: {
              id: this.$route.params.id,
            },
          }
        )
        .then((res) => this.handleGetDataSucc(res));
    },
    handleGetDataSucc(res) {
      res = res.data;
      if (res.ret && res.data) {
        const data = res.data;
        console.log(data);
        this.sightName = data.sightName;
        this.bannerImg = data.bannerImg;
        this.gallaryImgs = data.gallaryImgs;
        this.list = data.categoryList;
      }
    },
  },
  // 当组件加载完毕后，执行this.getDetailInfo()函数，发送请求
  mounted() {
    this.getDetailInfo();
  },
};
</script>

<style lang="scss" scoped>
.content {
  height: 30rem;
}
</style>